<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>OurBarangay.com >> Products</title>
        <link rel="Stylesheet" href="<?php echo base_url();?>assets/css/general.css" />
        <link rel="Stylesheet" href="<?php echo base_url();?>assets/css/common.css" />
        <script type="text/javascript" src="<?php echo base_url();?>assets/js/jquery/js/jquery-1.6.2.min.js"></script>
        <script type="text/javascript" src="<?php echo base_url();?>assets/js/asynch.js"></script>
        <style type="text/css">
            .main_article {
                margin-top: 0;
                margin-bottom: 25px;
                /*padding-bottom: 10px;
                border-bottom: 1px solid #bbb;*/
            }
            .main_article_content {
               margin: 5px 0px; 
            }
            /*hr {
                border: 1px solid #ccc;
            }*/
            img.art_img {
                width: 677px;
                height: 201px;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <?php $this->load->view('main_admin_panel'); ?>
            <?php $this->load->view('main_head'); ?>
            <div class="body">
                <?php $this->load->view('main_body_left'); ?>
                <div class="body_right">
                    <div class="prim_inf">
                        <div class="main_article_details"><a href="<?php echo base_url(); ?>index.php/products/crudProducts">Add a New Product</a></div>
                        <?php if(count($products) == 0) { ?>
                        <?php $this->load->view('main_slideshow');?>
                        <?php } ?>
                        <?php foreach ($products as $row) { ?>
                        <div class="main_article" id="news_id_<?php echo $row->product_id_pk; ?>">
                            <div class="main_article_title">
                                <?php echo $row->product_name; ?>
                            </div>
                            <div class="main_article_img">
                                <img class="art_img" src="<?php echo base_url() . $row->product_photo_path; ?>" />
                            </div>
                            <div class="main_article_content">
                                <?php echo $row->det_less; ?>&nbsp;<a href="<?php echo base_url();?>index.php/products">Read more...</a>
                              
                            </div>
                            <div class="main_article_details">
                      <!--          Posted on: <span style="font-weight: bold; color: #999;"><?php echo $row->product_date_posted;?>.</span>  <?php echo $row->product_address;?>.</span> -->
                                <?php if($this->session->userdata('user_resp') == 'admin') { ?>
                                <a href="<?php echo base_url(); ?>index.php/products/crudproducts?product_id_pk=<?php echo $row->product_id_pk;?>">Edit</a>
                                &nbsp;
                                <a id="product_delete" href="javascript:deleteProducts(<?php echo $row->product_id_pk;?>)">Delete</a>
                                <?php } ?>
                            </div>
                        </div>
                        <?php } ?>
                    </div>
                </div>
            </div>
            <div class="footer">
                <div class="footer_brgy_info">
                    Brgy Info
                </div>
                <div class="footer_sysnet">
                    Sysnet
                </div>
            </div>
        </div>
        <script type="text/javascript">
            $(document).ready(function() {
                <?php if($this->session->userdata('barangay_id') != '' || $this->session->userdata('barangay_id') != null) { ?>
                /*
                 * Asynchronous requests that are common
                 **/
                weeklyBulletin();
                latestBarangayUpdate();
                /*
                 * Asynchronous requests that are native to the page
                 **/
                //brgyDesc('edit');
                
                <?php } ?>
            });
            function deleteProducts(elem) {
                $.ajax({
                    type:"post",
                    url:"<?php echo base_url(); ?>index.php/products/deleteproducts",
                    data:"products_id="+elem,
                    success:function(data) {
                        $("#news_id_"+elem).fadeOut("5000");
                    },
                    error:function(data) {
                        alert("error"+data);
                    }
                });
            }
        </script>
    </body>
</html>
